package com.iot.modbus.execute.config;

import java.nio.ByteOrder;
import java.util.Objects;

/**
 * 指标相关配置
 */
public class MetricDataConfig {

    /**
     * 指标id
     */
    private String metricId;

    /**
     * 指标名称
     */
    private String metricName;

    /**
     * 指标单位
     */
    private String metricUnit;

    /**
     * 大端或小段
     */
    private ByteOrder byteOrder;


    private ConfigDataType dataType;

    /**
     * 开始地址
     */
    private int startOffset;

    /**
     * 几个字节(仅批量读取数据时填写)
     */
    private int numberOfRegisters;

    public String getMetricId() {
        return metricId;
    }

    public void setMetricId(String metricId) {
        this.metricId = metricId;
    }

    public String getMetricName() {
        return metricName;
    }

    public void setMetricName(String metricName) {
        this.metricName = metricName;
    }

    public String getMetricUnit() {
        return metricUnit;
    }

    public void setMetricUnit(String metricUnit) {
        this.metricUnit = metricUnit;
    }

    public ByteOrder getByteOrder() {
        return byteOrder;
    }

    public void setByteOrder(ByteOrder byteOrder) {
        this.byteOrder = byteOrder;
    }

    public ConfigDataType getDataType() {
        return dataType;
    }

    public void setDataType(ConfigDataType dataType) {
        this.dataType = dataType;
    }

    public int getStartOffset() {
        return startOffset;
    }

    public void setStartOffset(int startOffset) {
        this.startOffset = startOffset;
    }

    public int getNumberOfRegisters() {
        return numberOfRegisters;
    }

    public void setNumberOfRegisters(int numberOfRegisters) {
        this.numberOfRegisters = numberOfRegisters;
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        MetricDataConfig that = (MetricDataConfig) o;
        return Objects.equals(metricId, that.metricId) && Objects.equals(metricName, that.metricName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(metricId, metricName);
    }


    @Override
    public String toString() {
        return "MetricDataConfig{" +
                "metricId='" + metricId + '\'' +
                ", metricName='" + metricName + '\'' +
                ", metricUnit='" + metricUnit + '\'' +
                ", byteOrder=" + byteOrder +
                ", dataType=" + dataType +
                ", startOffset=" + startOffset +
                ", numberOfRegisters=" + numberOfRegisters +
                '}';
    }
}
